﻿//using System;
//using NthDownload.Contracts.Plugins.Downloads;
//using System.Threading.Tasks;
//using System.IO;
//using NthDownload.Contracts;

//namespace NthDownload.DownloadPlugins.LocalDownload
//{
//    public class LocalDownloadFactory : IDownloadFactory
//    {
//        private readonly string _pluginGUID;

//        public LocalDownloadFactory(string pluginGUID)
//        {
//            _pluginGUID = pluginGUID;
//        }

//        public IDownload CreateDownload(string path, string destinationPath)
//        {
//            LocalDownload download = new LocalDownload(path)
//            {
//                GUID = Guid.NewGuid().ToString(),
//                ParentGUID = _pluginGUID,
//                FileName = Path.GetFileName(path),
//                Description = Path.GetFileName(path),
//                DestinationFolder = destinationPath,
//                DateCreated = DateTime.Now,
//                Status = DownloadStatuses.Ready
//            };
//            return download;
//        }

//        public Task InitializeDownload(IDownload download)
//        {
//            Task task = new Task(() =>
//            {
//                LocalDownload localDownload = download as LocalDownload;

//                FileStream fs = new FileStream(localDownload.Path, FileMode.Open, FileAccess.Read, FileShare.Read);

//                localDownload.ChunkSize = 1024 * 512;
//                localDownload.CanQueue = true;
//                localDownload.CanResume = true;
//                localDownload.HasSize = true;
//                localDownload.IsInitialized = true;
//                localDownload.Size = fs.Length;

//                fs.Close();
//            });

//            task.Start();

//            return task;
//        }
//    }
//}
